﻿using dbasyn.model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dbasyn
{
    public class QuestDb
    {
        SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
        {
            ConnectionString = "host=pod2;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;",
            DbType = SqlSugar.DbType.QuestDB,
            IsAutoCloseConnection = true
        },
          db => {
              //5.1.3.24统一了语法和SqlSugarScope一样，老版本AOP可以写外面

              db.Aop.OnLogExecuting = (sql, pars) =>
              {
                  Console.WriteLine(sql);//输出sql,查看执行sql 性能无影响

                  //5.0.8.2 获取无参数化SQL 对性能有影响，特别大的SQL参数多的，调试使用
                  //Console.WriteLine(UtilMethods.GetSqlString(DbType.QuestDB, sql, pars));
              };

                   //注意多租户 有几个设置几个
                   //db.GetConnection(i).Aop

          });
      

        public void exec(String sql)
        {
             Db.Ado.ExecuteCommand(sql);
        }
        public void insert(lxb_kaoqin_log lxb)
        {
            try
            {
                Db.Insertable(lxb).ExecuteCommand();
            }
            catch (Exception er)
            {

                Console.WriteLine(er.Message);
                throw er;
            }
           
        }
        public void insert(lxb_admin_log lxb)
        {
            try
            {
                Db.Insertable(lxb).ExecuteCommand();
            }
            catch (Exception er)
            {

                Console.WriteLine(er.Message);
                throw er;
            }

        }

        internal void insertMoney(lxb_money lxb_money)
        {
            try
            {
                Db.Insertable(lxb_money).ExecuteCommand();
            }
            catch (Exception er)
            {
              
                Console.WriteLine(er.Message);
                throw er;
            }
        }
    }
}
